# -*- coding: utf-8 -*-
from wordcloud import WordCloud
from wordcloud import STOPWORDS
from PIL import Image
import jieba
import matplotlib.pyplot as plt
import numpy as np

import sys
import os.path
import base64
import requests
from bs4 import BeautifulSoup


with open('content.txt') as fd:
    content = fd.read()

mask = np.array(Image.open('mask.jpg'))
text = ' '.join(jieba.cut(content))

wc = WordCloud(font_path='simhei.ttf', background_color='black', max_font_size=50,
    random_state=42, stopwords=STOPWORDS, mask=mask)
r = wc.generate(text)

plt.figure()
plt.imshow(r)
plt.axis('off')
plt.show()
